<type_traits>

public member function
<type_traits>

std::integral_constant::operator value_type

constexpr operator value_type();
Returns value
Returns the value of the integral_constant.

For true_type, this istrue.
For false_type, this isfalse.
For any other instantitiation of integral_constant this is the same as its second template parameter.

参数



返回值

The value of the integral_constant.
value_typeis an alias of the first class template parameter (T).

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// integral_constant::operator value_type example
#include <iostream>
#include <type_traits>

int main() {
  // is_integral<T> inherits from integral_constant

  if ( std::is_integral<int>() )
    std::cout << "int is an integral type" << std::endl;

  // same result as:
  if ( std::is_integral<int>::value )
    std::cout << "int is an integral type" << std::endl;

  return 0;
}

输出
int is an integral type
int is an integral type


另见